package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.ChargeTime;
import com.lrkj.payfee.service.IChargeTimeService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 收费时间Controller
 *
 * @author yajun_ren
 * @date 2021-07-26
 */
@RestController
@RequestMapping("/payfee/CharTime")
public class ChargeTimeController extends BaseController
{
    @Autowired
    private IChargeTimeService chargeTimeService;

    /**
     * 查询收费时间列表
     */
    @ApiOperation(value = "查询收费时间列表", notes = "查询收费时间列表")
    @GetMapping("/list")
    public TableDataInfo list(ChargeTime chargeTime)
    {
        startPage();
        List<ChargeTime> list = chargeTimeService.selectChargeTimeList(chargeTime);
        return getDataTable(list);
    }

    /**
     * 导出收费时间列表
     */
	@ApiOperation(value = "导出收费时间列表", notes = "导出收费时间列表")
    @PreAuthorize("@ss.hasPermi('payfee:CharTime:export')")
    @Log(title = "收费时间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ChargeTime chargeTime)
    {
        List<ChargeTime> list = chargeTimeService.selectChargeTimeList(chargeTime);
        ExcelUtil<ChargeTime> util = new ExcelUtil<ChargeTime>(ChargeTime.class);
        return util.exportExcel(list, "收费时间数据");
    }

    /**
     * 获取收费时间详细信息
     */
	@ApiOperation(value = "获取收费时间详细信息", notes = "获取收费时间详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:CharTime:query')")
    @GetMapping(value = "/{chartimId}")
    public AjaxResult getInfo(@PathVariable("chartimId") String chartimId)
    {
        return AjaxResult.success(chargeTimeService.selectChargeTimeById(chartimId));
    }

    /**
     * 新增收费时间
     */
	  @ApiOperation(value = "新增收费时间", notes = "新增收费时间")
    @PreAuthorize("@ss.hasPermi('payfee:CharTime:add')")
    @Log(title = "收费时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeTime chargeTime)
    {
        return toAjax(chargeTimeService.insertChargeTime(chargeTime));
    }

    /**
     * 修改收费时间
     */
	 @ApiOperation(value = "修改收费时间", notes = "修改收费时间")
    @PreAuthorize("@ss.hasPermi('payfee:CharTime:edit')")
    @Log(title = "收费时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeTime chargeTime)
    {
        return toAjax(chargeTimeService.updateChargeTime(chargeTime));
    }

    /**
     * 删除收费时间
     */
	 @ApiOperation(value = "删除收费时间", notes = "删除收费时间")
    @PreAuthorize("@ss.hasPermi('payfee:CharTime:remove')")
    @Log(title = "收费时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chartimIds}")
    public AjaxResult remove(@PathVariable String[] chartimIds)
    {
        return toAjax(chargeTimeService.deleteChargeTimeByIds(chartimIds));
    }
}
